﻿{include file='pub/header'/}
<title>订单列表</title>
</head>
<body class="pos-r">
<div>
    <nav class="breadcrumb">{$breadNav} <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                           href="javascript:location.replace(location.href);" title="刷新"><i
            class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="page-container">
        <div class="mt-20">
            <table class="table table-border table-bordered table-bg table-hover table-sort">
                <thead>
                <tr class="text-c">
                    <th width="50">订单编号</th>
                    <th width="60">下单时间</th>
                    <th width="30">下单会员</th>
                    <th width="30">会员手机号</th>
                    <th width="30">订单状态</th>
                    <th width="30">配送状态</th>
                    <th width="30">支付方式</th>
                    <th width="30">订单总金额</th>
                    <th width="60">支付总金额</th>
                    <th width="60">配送方式</th>
                    <th width="60">预计配送/到店自提时间</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody>
                {foreach $list as $item}
                <tr class="text-c va-m">
                    <td>{$item.order_no}</td>
                    <td>{$item.create_time}</td>
                    <td>{$item.username}</td>
                    <td>{$item.phone}</td>
                    <td>{:config('order_status')[$item.order_status]}</td>
                    <td class="is_send">
                        {if $item.is_send == 0}
                        未配送
                        {else/}
                        已配送
                        {/if}
                    </td>
                    <td>{:config('pay_type')[$item.pay_type]}</td>
                    <td>{$item.shop_cost}</td>
                    <td>{$item.real_cost}</td>
                    <td class="text-c">
                        {if $item.dispatch_type == 0}
                        店铺配送
                        {else/}
                        到店自提
                        {/if}
                    </td>
                    <td>{$item.dispatch_time}</td>
                    <td class="td-manage">
                        <a style="text-decoration:none" class="ml-5" onClick="order_detail('{$item.id}')"
                           href="javascript:;" title="订单详情">
                            <i class="Hui-iconfont">&#xe623;</i>订单详情
                        </a>
                        <a style="text-decoration:none" class="ml-5"
                           href="{:url('order_print', ['order_id'=>$item.id])}" target="_blank" title="打印小票">
                            <i class="Hui-iconfont">&#xe623;</i>打印小票
                        </a>
                        {if ($item.pay_status == 1 && $item.is_apply_refund == 0)}
                        <a href="javascript:;" class="ml-5" style="text-decoration: none;"
                           onclick="refund_order('{$item.order_no}')"><i class="Hui-iconfont Hui-iconfont-edit"></i>商品退货处理</a>
                        {/if}
                        {if $item.is_send != 1}
                        <a style="text-decoration:none" class="ml-5" onClick="send(this,'{$item.id}')"
                           href="javascript:;">
                            <i class="Hui-iconfont">&#xe623;</i>待配送
                        </a>
                        {/if}
                        {if $item.is_send == 1 && time() gt strtotime($item.send_time)+60*60 && $item.order_status == 1}
                        <a style="text-decoration:none" class="ml-5" onClick="sure_order(this,'{$item.id}')"
                           href="javascript:;" title="确认收获">
                            <i class="Hui-iconfont">&#xe6a7;</i>确认收获
                        </a>
                        {/if}
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>
        </div>
    </div>
</div>
<audio src="/wave.mp3" id="tips"></audio>

{include file='pub/footer'/}
<script type="text/javascript">
    /*$('.table-sort').dataTable({
        "aaSorting": [[1, "desc"]],//默认第几个排序
        "bStateSave": false,//状态保存
        "aoColumnDefs": [
            {"orderable": false, "aTargets": [7]}// 制定列不参与排序
        ],
    });*/

    function refund_order(order_id) {
        layer_show('订单商品', "{:url('Order/refund_goods')}?order_id=" + order_id);
    }

    //订单详情
    function order_detail(order_id) {
        layer_show('订单详情', "{:url('Order/order_detail')}?order_id=" + order_id);
    }

    //订单配送
    function send(o, order_id) {
        layer.confirm('确认配送订单？', function () {
            $.post("{:url('send_order')}", {'order_id': order_id}, function (res) {
                if (res.code == 1) {
                    $(o).parent().siblings('.is_send').html("已配送");
                    $(o).parent().parent().remove();
                }
                layer.msg(res.msg);
            });
        });
    }

    $(function () {
        setInterval(function () {
            $.post("{:url('getNewOrder')}", null, function (res) {
                if (res.code == 1) {
                    document.getElementById('tips').play();
                    setTimeout(function () {
                        location.reload();
                    }, 3000);
                }
            });
        }, 40000);
    })

</script>
</body>
</html>